{#
/**
 * @file
 * section
 *
 * See section.wingsuit.yaml for documentation.
 */
#}

{# SETTINGS #}
{% if padding_bottom is not defined %}
  {% set padding_bottom = 'default' %}
{% endif %}

{%- set header -%}{%- block header -%}{{ header }}{% endblock %}{% endset %}
{% set region_attributes = region_attributes|default([]) %}
{% set grid %}
  {%- set column_1 -%}{%- block column_1 -%}{{ _context['column_1' ] }}{% endblock %}{% endset %}
  {%- set column_2 -%}{%- block column_2 -%}{{ _context['column_2' ] }}{% endblock %}{% endset %}
  {%- set column_3 -%}{%- block column_3 -%}{{ _context['column_3' ] }}{% endblock %}{% endset %}
  {%- set column_4 -%}{%- block column_4 -%}{{ _context['column_4' ] }}{% endblock %}{% endset %}
  {%- set column_5 -%}{%- block column_5 -%}{{ _context['column_5' ] }}{% endblock %}{% endset %}
  {% set cells = [] %}
  {%- for i in 1..columns -%}
    {% set cells = cells|merge([_context['column_' ~ i ]]) %}
  {% endfor %}
  {% set columns_width = columns_width|default(_context['columns_width_' ~ columns ]) %}
  {% embed "@organisms/grid/grid.twig" with {attributes: create_attribute(), cells: cells, columns_width: columns_width} %}
    {#
      Layout Builder regions attributes should be part of the section cell.
    #}
    {% block cell_outer %}
      {% set column_name = 'column_' ~ column_i %}
      {% set current_region_attributes = region_attributes[column_name]|default(create_attribute()) %}
      <div class="{{ cell_attributes.class }} {{ current_region_attributes.class }}" {{ cell_attributes|without('class') }} {{ current_region_attributes|without('class') }}>
          {{ cell }}
      </div>
    {% endblock %}
  {% endembed %}
{% endset %}

{# TEMPLATES #}
{% embed "@organisms/container/container.twig" with {
  attributes: attributes,
  content: grid,
  width: width,
  padding_x: padding_x,
  padding_top: padding_top,
  padding_bottom: padding_bottom,
  bg: bg,
  header: header
} only %}
  {% block content %}
  {% if header is not empty %}
    <div class="mb-5 md:mb-10">{{ header }}</div>
  {% endif %}
  {{ content }}
  {% endblock %}
{% endembed %}
